/**
 * 微信客服统计
 * - 使用自定义封装组件，简化代码，统一管理。
 * - 2025-07-12 13:14:21 tzj
 * */

import BaseComponent from "../../components/BaseComponent";
import {mrhzApi} from "../../services/basic";

// 要显示的form表单
const formItemList =
    [
        'positions',
        'accounts',
        {
            name: "person",
            label: "微信客服",
            keyword: "lxr"
        },
        "companies",
        {
            name: "dateRange",
            label: "留资日期",
            showTime: true,
            start: "qsrq",
            end: "jsrq"
        },
        "project",
    ];
// 显示的按钮
const buttons = ["query", "export",];
// 表格列信息
const columns = [
    {
        title: '微信客服',
        dataIndex: 'xm',
        sumName: '合计'
    },
    {
        title: '等待跟进',
        dataIndex: 'ddgj',
        sorter: true
    },
    {
        title: '已经联系',
        dataIndex: 'yjlx',
        sorter: true
    },
    {
        title: '已经预约',
        dataIndex: 'yjyy',
        sorter: true
    },
    {
        title: '预约未到店',
        dataIndex: 'yywdd',
        sorter: true
    },
    {
        title: '到店未成交',
        dataIndex: 'ddwcj',
        sorter: true
    },
    {
        title: '到店已成交',
        dataIndex: 'ddycj',
        sorter: true
    },
    {
        title: '他人已成交',
        dataIndex: 'trycj',
        sorter: true
    },
    {
        title: '跟进被删除',
        dataIndex: 'gjbsc',
        sorter: true
    },
    {
        title: '无效客户',
        dataIndex: 'wxkh',
        sorter: true
    },
    {
        title: '异公司到店',
        dataIndex: 'ygsdd',
        sorter: true
    },
    {
        title: '异公司成交',
        dataIndex: 'ygscj',
        sorter: true
    },
    {
        title: '潜在客户',
        dataIndex: 'qzkh',
        sorter: true
    },
    {
        title: '跟进待通过',
        dataIndex: 'gjdtg',
        sorter: true
    },
    {
        title: '留资数量',
        dataIndex: 'zlz',
        sorter: true,
        render(text, item) {
            return (~~item.ddgj) + (~~item.yjlx) + (~~item.yjyy) + (~~item.yywdd) + (~~item.ddwcj) + (~~item.ddycj) + (~~item.trycj) + (~~item.gjbsc) + (~~item.wxkh) + (~~item.ygsdd) + (~~item.ygscj) + (~~item.qzkh) + (~~item.gjdtg);
        },
        formula: "=SUM({{ddgj}},{{yjlx}},{{yjyy}},{{yywdd}},{{ddwcj}},{{ddycj}},{{trycj}},{{gjbsc}},{{wxkh}},{{ygsdd}},{{ygscj}},{{qzkh}},{{gjdtg}})"
    },
    {
        title: '有效留资',
        dataIndex: 'yxlz',
        sorter: true,
        // dataIndex: 'zlz',
        // render(text, item) {
        //     return (~~item.gjbsc) + (~~item.trycj) + (~~item.ddycj) + (~~item.ddwcj) + (~~item.yywdd) + (~~item.yjyy) + (~~item.yjlx) + (~~item.ddgj) + (~~item.ygsdd) + (~~item.ygscj);
        // },
        // formula:"=SUM({{gjbsc}},{{trycj}},{{ddycj}},{{ddwcj}},{{yywdd}},{{yjyy}},{{yjlx}},{{ddgj}},{{ygsdd}},{{ygscj}})"
    },
    {
        title: '三天外跟进',
        dataIndex: 'tdwgj',
    },
    {
        title: '三天外填单',
        dataIndex: 'tdwtd',
    },
];

class Shtj extends BaseComponent {
    constructor(props) {
        super(props);
        this.state = {
            ...this.state,
            formItemList,
            buttons,
            // columns,
            filename: "鹏成车邦留资情况报表(微信)",
            tableTitle: true,
            queryAll: true,
            sumRow: true,
        }
        this.columns = columns;
        this.queryApi = mrhzApi.getPagewx;
        this.hasLzModal = true;
    }

    // dataProcess = list => {
    //     list.forEach(item => {
    //         const zlz = (~~item.gjbsc) + (~~item.trycj) + (~~item.ddycj) + (~~item.ddwcj) + (~~item.yywdd) + (~~item.yjyy) + (~~item.yjlx) + (~~item.ddgj) + (~~item.ygsdd) + (~~item.ygscj);
    //         item.zlz = zlz;
    //     })
    //     return list;
    // }

    onRowDoubleClick = (record) => {
        if (record.children) return;
        // gh,xm
        const params = {
            ...this.form.dataForm,
            lxr: record.gh,
        }
        params.qsrq = params.qsrq ? params.qsrq.slice(0, 10) : null;
        params.zzrq = params.jsrq ? params.jsrq.slice(0, 10) : null;
        delete params.jsrq;
        console.log(params)
        // const config = [
        //     {
        //         key: "xm",
        //         val: record.xm,
        //         label: "姓名",
        //     }]
        // 日期范围
        this.lzModalRef.open(params, {});
    }
}

export default Shtj;